package com.xzy.util;

public class JSONResult<T> {
    int code;
    String message;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    T data;
    public JSONResult(ResultCode resultCode)
    {
        this.code=resultCode.code;
        this.message=resultCode.message;
    }
    public JSONResult(ResultCode resultCode,T data)
    {
        this.code=resultCode.code;
        this.message=resultCode.message;
        this.data=data;
    }
    public JSONResult (String message)
    {
        this.message=message;
    }
    public static   JSONResult SUCCESS(){
        return new JSONResult(ResultCode.SUCCESS);
    }

    public static <T> JSONResult SUCCESS(T data){
        return new JSONResult(ResultCode.SUCCESS, data);
    }

    public static JSONResult ERROR(){
        return new JSONResult(ResultCode.ERROR);
    }

    public static JSONResult ERROR(String message){
        return new JSONResult(message);
    }

    public static JSONResult PERMISSION_UNAUTHORISE(){return new JSONResult(ResultCode.PERMISSION_UNAUTHORISE);}

    public static JSONResult PERMISSION_UNAUTHORISE(String message){return new JSONResult(message);}


}
